import uvicorn,contextlib,threading,time
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles

from vendor.middleware import origins, router, errors, logs,multithreading

app = FastAPI(debug=True,version="0.1")
app.mount("/report", StaticFiles(directory="public/report"), name="static")
#注册日志
logs.log_requests(app)
# 注册自定义错误处理器
errors.registerCustomErrorHandle(app)
# 注册跨域
origins.Access_Headers(app)
#注册路由
router.CustomRouter(app)

# 多线程支持
start_server=multithreading.start_server(app)
if __name__ == '__main__':
    #uvicorn.run('main:app',host='0.0.0.0', port=8088, reload=True)
    th = threading.Thread(target=start_server)
    th.start()